home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / hsrc_117.zip / SCREEN2.ASM < prev    next >
Assembly Source File  |  1990-11-25  |  6KB  |  386 lines

  1. ;
  2. ; PUBLIC DOMAIN
  3. ; (swiped from MSGED 2.00 archive--MK)
  4. ;
  5.  
  6. .model large
  7.  
  8. extrn _vbase:word
  9. extrn _maxx:word
  10. extrn _maxy:word
  11. extrn _current_color:byte
  12. extrn _videomethod:word
  13.  
  14. public DCLS, DPUTC, DPUTS, DCLRWND, DSCROLLUP, DSCROLLDN
  15.  
  16. .CODE
  17.  
  18. DCLS    proc far
  19.  
  20.     push bp
  21.     mov bp,sp
  22.  
  23.     push di
  24.     mov es,_vbase        ; set the es segment to the bottom of video
  25.  
  26.     mov bx,_maxx
  27.     mov ax,_maxy
  28.     mul bl                ; determine size of screen in words
  29.  
  30.     mov cx,ax            ; set up the count for the screen size
  31.     xor di,di            ; point es:di to start of screen
  32.  
  33.     mov ah,_current_color ; set the attribute
  34.     mov al,20h            ; write a space
  35.  
  36.     cld                 ; make sure we're going in the right direction...
  37.     repnz stosw            ; slam that sucker out to memory..
  38.  
  39.     pop di
  40.     pop bp
  41.  
  42.     ret
  43.  
  44. DCLS    endp
  45.  
  46. DPUTC    proc far
  47.     push bp
  48.     mov bp,sp
  49.  
  50.     pushf
  51.     cld
  52.  
  53.     cmp _videomethod,1
  54.     je bsputc
  55.  
  56.     mov bx,[bp+6]        ; get the character to write
  57.     mov dx,[bp+8]        ; get the y location
  58.     mov es,_vbase        ; set up the video segment
  59.  
  60.     mov ax,_maxx
  61.     dec dl                ; off by one because of 1 base coords
  62.     mul dl
  63.     add ax,[bp+10]        ; get base video offset
  64.     dec ax                ; off by one because of 1 based coords
  65.     shl ax,1            ; double it (because of attribute)
  66.  
  67.     mov bh,_current_color
  68.  
  69.     xchg ax,bx
  70.     mov es:[bx],ax        ; put it on the screen
  71.  
  72.     popf
  73.     pop bp
  74.     ret 6
  75.  
  76. bsputc: mov ah,02h
  77.     mov cx,[bp+8]
  78.     mov dx,[bp+10]
  79.     mov dh,cl
  80.     dec dh
  81.     dec dl
  82.     mov bh,0
  83.     int 10h
  84.  
  85.     mov ax,[bp+6]
  86.     mov ah,09h
  87.     mov bh,0
  88.     mov cx,1
  89.     mov bl,_current_color
  90.     int 10h
  91.  
  92.     popf
  93.     pop bp
  94.     ret 6
  95.  
  96. DPUTC    endp
  97.  
  98. DPUTS    proc far
  99.  
  100.     push bp
  101.     mov bp,sp
  102.  
  103.     pushf
  104.     cld
  105.  
  106.     cmp _videomethod,1
  107.     je bsputs
  108.  
  109.     push di             ; save needed registers
  110.     push si
  111.     push ds
  112.  
  113.     mov ax,_maxx
  114.     mov es,_vbase        ; set up the video segment
  115.     mov dh,_current_color
  116.  
  117.     lds si,[bp+6]        ; get offset
  118.     mov bx,[bp+10]        ; get the y location
  119.     mov di,[bp+12]        ; get the x location
  120.  
  121.     dec bl                ; off by one because of 1 base coords
  122.     mul bl
  123.     add di,ax            ; get base video offset
  124.     dec di                ; off by one because of 1 based coords
  125.     shl di,1            ; double it (because of attribute)
  126.  
  127.     mov ah,dh            ; put the attribute in ah
  128.     mov dx,si
  129.  
  130.  
  131. l0:    lodsb                ; load character
  132.     cmp al,0            ; test for zero byte
  133.     jz l1                ; end of string
  134.     stosw                ; write character and attribute
  135.     jmp l0
  136.  
  137. l1:    sub si,dx            ; how many characters were written
  138.     mov ax,si
  139.     dec ax
  140.  
  141.     pop ds                ; restore registers
  142.     pop si
  143.     pop di
  144.  
  145.     popf
  146.  
  147.     pop bp
  148.     ret 8
  149.  
  150. bsputs: mov cx,[bp+10]
  151.     mov dx,[bp+12]
  152.     mov dh,cl
  153.     dec dh
  154.     dec dl
  155.     mov bh,0
  156.     
  157.     push ds
  158.     pop es
  159.     push si
  160.     push di
  161.     lds si,[bp+6]
  162.     mov di,si
  163.     mov bl,es:_current_color
  164.     mov cx,1
  165.  
  166. l5:    mov ah,2
  167.     int 10h
  168.     inc dl
  169.     mov ah,9
  170.     lodsb    
  171.     cmp al,0
  172.     jz l6
  173.     int 10h
  174.     jmp l5
  175.  
  176. l6:    mov ax,si
  177.     sub ax,di
  178.     dec ax
  179.     pop di
  180.     pop si
  181.     push es
  182.     pop ds
  183.  
  184.     popf
  185.  
  186.     pop bp
  187.     ret 8
  188.     
  189. DPUTS endp
  190.  
  191. DCLRWND proc far
  192.     push bp
  193.     mov bp,sp
  194.  
  195.     push di
  196.     push si
  197.  
  198.     mov es,_vbase    ; video segment
  199.  
  200.     mov di,[bp+12]
  201.  
  202.     mov cx,[bp+6]
  203.     sub cx,[bp+10]    ; how many lines?
  204.     inc cx
  205.  
  206.     mov ax,_maxx
  207.     mov bx,[bp+10]
  208.     dec bl
  209.     mul bl
  210.     add di,ax
  211.     dec di
  212.     mov si,di
  213.  
  214.     mov ah,_current_color
  215.     mov al,20h
  216.  
  217.     mov bx,[bp+8]
  218.     sub bx,[bp+12]    ; how many columns
  219.     inc bx
  220.  
  221. l2: mov dx,bx
  222.     xchg cx,dx
  223.     shl di,1
  224.     rep stosw
  225.     add si,_maxx
  226.     mov di,si
  227.     xchg cx,dx
  228.     loop l2
  229.  
  230.     pop si
  231.     pop di
  232.  
  233.     pop bp
  234.     ret 8
  235.  
  236. DCLRWND endp
  237.  
  238. DSCROLLUP proc far
  239.  
  240.     push bp
  241.     mov bp,sp
  242.  
  243.     sub sp,2        ; allocate a local
  244.  
  245.     pushf
  246.  
  247.     push di         ; save registers
  248.     push si
  249.     push ds
  250.  
  251.     cld             ; set direction to forward
  252.  
  253.     mov al,_current_color
  254.     mov [bp-2],al
  255.  
  256.     mov es,_vbase    ; point to the video screen
  257.     mov ax,_maxx    ; how many columns on the screen
  258.     mov si,ax
  259.  
  260.     mov cx,[bp+6]
  261.     sub cx,[bp+10]    ; how many lines?
  262.  
  263.     mov di,[bp+12]    ; x offset of first line
  264.     mov bx,[bp+10]    ; y offset of first line
  265.     dec bl            ; adjust for 1 base
  266.     mul bl
  267.     add di,ax
  268.     dec di            ; first line offset in di
  269.  
  270.     shl si,1
  271.     shl di,1
  272.  
  273.     mov ax,si        ; save maxx * 2
  274.     add si,di        ; offset of second line in si
  275.  
  276.     push es
  277.     pop ds            ; point both at video
  278.  
  279.     mov bx,[bp+8]
  280.     sub bx,[bp+12]    ; how many columns
  281.     inc bx
  282.  
  283. l3: mov dx,bx
  284.     xchg cx,dx
  285.     push si         ; store this offset
  286.     rep movsw
  287.     pop di
  288.     mov si,ax
  289.     add si,di
  290.     xchg cx,dx
  291.     loop l3
  292.  
  293.     xchg cx,bx
  294.     mov ah,[bp-2]
  295.     mov al,20h
  296.     rep stosw
  297.  
  298.     pop ds            ; restore registers
  299.     pop si
  300.     pop di
  301.  
  302.     popf
  303.  
  304.     mov sp,bp        ; drop locals
  305.  
  306.     pop bp
  307.     ret 8
  308.  
  309. DSCROLLUP endp
  310.  
  311. DSCROLLDN proc far
  312.  
  313.     push bp
  314.     mov bp,sp
  315.  
  316.     sub sp,2        ; allocate a local
  317.  
  318.     pushf
  319.  
  320.     push di         ; save registers
  321.     push si
  322.     push ds
  323.  
  324.     cld             ; set direction to forward
  325.  
  326.     mov al,_current_color
  327.     mov [bp-2],al
  328.  
  329.     mov es,_vbase    ; point to the video screen
  330.     mov ax,_maxx    ; how many columns on the screen
  331.     mov si,ax
  332.  
  333.     mov cx,[bp+6]
  334.     sub cx,[bp+10]    ; how many lines?
  335.  
  336.     mov di,[bp+12]    ; x offset of first line
  337.     mov bx,[bp+6]    ; y offset of last line
  338.     dec bl            ; adjust for 1 base
  339.     mul bl
  340.     add di,ax
  341.     dec di            ; last line offset in si
  342.  
  343.     shl si,1
  344.     shl di,1
  345.  
  346.     mov ax,si        ; save maxx * 2
  347.     mov si,di
  348.     sub si,ax        ; offset of second to last line in di
  349.  
  350.     push es
  351.     pop ds            ; point both at video
  352.  
  353.     mov bx,[bp+8]
  354.     sub bx,[bp+12]    ; how many columns
  355.     inc bx
  356.  
  357. l4: mov dx,bx
  358.     xchg cx,dx
  359.     push si        ; store this offset
  360.     rep movsw
  361.     pop di
  362.     mov si,di
  363.     sub si,ax
  364.     xchg cx,dx
  365.     loop l4
  366.  
  367.     xchg cx,bx
  368.     mov ah,[bp-2]
  369.     mov al,20h
  370.     rep stosw
  371.  
  372.     pop ds            ; restore registers
  373.     pop si
  374.     pop di
  375.  
  376.     popf
  377.  
  378.     mov sp,bp        ; drop locals
  379.  
  380.     pop bp
  381.     ret 8
  382.  
  383. DSCROLLDN endp
  384.  
  385. end
  386.